<template>
    <div class="page">
        <div class="bg-color-box">
            <!--顶部导航栏-->
            <van-nav-bar class="nav-bar-box" :left-arrow="true" @click-left="onClickLeft">
                <div slot="left">
                    <i class="go-back-icon"></i>
                    <span class="title">住户管理</span>
                </div>

                <div slot="right">
                    <i class="add-icon"></i>
                    <span class="title">添加</span>
                </div>
            </van-nav-bar>
        </div>

        <div class="module-box search">
            <input class="input" type="text" v-model="queryVal" placeholder="请输入业主名称/电话"/>
            <i class="icon-btn" @click="clickSearch()"></i>
        </div>

        <!--住户列表-->
        <div class="module-box family-list">
            <!--小区名称-->
            <div class="village-name">香楠小区</div>

            <div class="classA" v-for="(itemA,indexA) in 3" :key="indexA">
                <div class="titleA" @click="clickTitleA(indexA)">
                    <span>一级名称</span>
                    <i class="tri-icon" :class="{'tri-up-icon' : indexA === showClassA}"></i>
                </div>

                <div class="classB" v-for="(itemB,indexB) in 3" :key="indexB" v-if="indexA === showClassA">
                    <div class="titleB" @click="clickTitleB(indexB)">
                        <span>二级名称</span>
                        <i class="tri-icon" :class="{'tri-up-icon' : indexB === showClassB}"></i>
                    </div>

                    <div class="classC" v-for="(itemC,indexC) in 3" :key="indexC" v-if="indexB === showClassB">
                        <div class="titleC">
                            <span class="room">1001室</span>
                            <div class="name">
                                <span>王小明</span>
                                <i class="right-icon"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</template>

<script>
    import {NavBar} from 'vant';

    export default {
        name: 'familyManage',

        components: {
            [NavBar.name]: NavBar,
        },

        props: {},

        data() {
            return {
				queryVal: '',
				showClassA: '',
				showClassB: '',
            }
        },

        mounted() {

        },

        methods: {
            onClickLeft(){
                this.$router.go(-1);
            },

            //点击搜索按钮
			clickSearch(){
            	console.log(this.queryVal);
            },

            //点击一级title
			clickTitleA(indexA){
				if(this.showClassA === indexA){
					this.showClassA = '';
					this.showClassB = '';
                }else{
					this.showClassA = indexA;
					this.showClassB = '';
                }
			},
			//点击二级title
			clickTitleB(indexB){
				if(this.showClassB === indexB){
					this.showClassB = '';
				}else{
					this.showClassB = indexB;
				}
            },
        },
    }
</script>

<style lang="scss" scoped>
    /*顶部添加图标*/
    .add-icon{
        display: inline-block;
        width: 18px;
        height: 18px;
        background: url("../assets/images/add-icon.png") no-repeat;
        background-size: cover;
        vertical-align: middle;
    }

     /*搜索框样式*/
    .search{
        position: relative;

        .input{
            width: 100%;
            height: 42px;
            border: none;
            background-color: transparent;
            padding-left: 16px;
            padding-right: 50px;
            font-size: 15px;
            box-sizing: border-box;
        }
        .icon-btn{
            display: inline-block;
            width: 24px;
            height: 24px;
            background: url("../assets/images/search-icon.png") no-repeat;
            background-size: cover;
            position: absolute;
            top: 8px;
            right: 12px;
        }
    }

    .family-list{
        font-size: 15px;
        color: #222222;

        .village-name{
            padding: 10px;
            font-size: 18px;
            color: #222222;
            border-bottom: solid 1px #ededed;
        }

        span{
            vertical-align: middle;
        }
        .tri-icon{
            display: inline-block;
            width: 10px;
            height: 10px;
            background: url("../assets/images/tri-donw-icon.png") no-repeat;
            background-size: cover;
            vertical-align: middle;

            &.tri-up-icon{
                background: url("../assets/images/tri-up-icon.png") no-repeat;
                background-size: cover;
            }
        }
        .titleA{
            font-weight: bold;
            padding: 10px 0;
            padding-left: 30px;
            border-bottom: solid 1px #f0f0f0;
        }
        .titleB{
            padding: 10px 0;
            padding-left: 50px;
            border-bottom: solid 1px #f0f0f0;
        }
        .titleC{
            color: #666666;
            padding: 10px 0;
            padding-left: 70px;
            border-bottom: solid 1px #f0f0f0;

            .name{
                float: right;

                .right-icon{
                    display: inline-block;
                    width: 15px;
                    height: 15px;
                    background: url("../assets/images/right-icon.png") no-repeat;
                    background-size: cover;
                    margin-right: 20px;
                    vertical-align: middle;
                }
            }
        }
    }
</style>

